package cn.tedu.mall.seckill.controller;

import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.pojo.seckill.vo.SeckillSkuVO;
import cn.tedu.mall.seckill.service.ISeckillSkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhangyiping
 * @date 2024/1/19
 */
@RestController
@RequestMapping("/seckill/sku")
@Api(tags = "订单秒杀功能之查询sku")
public class SeckillSkuController {

    @Autowired
    private ISeckillSkuService seckillSkuService;

    @GetMapping("/list/{spuId}")
    @ApiOperation(value = "根据spuId查询sku")
    @PreAuthorize("permitAll()")
    public JsonResult<List<SeckillSkuVO>> getSkuBySpuId(@PathVariable("spuId") Long spuId) {
        List<SeckillSkuVO> seckillSkuVOS = seckillSkuService.listSeckillSkus(spuId);
        return JsonResult.ok(seckillSkuVOS);
    }

}
